__precompile__()

module NanoTimes

# this module uses and exports Time24 as an alias for Base.Dates.Time

export UniversalTime, LocalTime, NanoTime,
    isuniversaltime, islocaltime,
    Duration, TimeSpan,
    Clock, value,
    Date, DateTime, Time24,
    Year, Month, Week, Day,
    Hour, QuarterHour, Minute, Second,
    Millisecond, Microsecond, Nanosecond,
    year, month, week, day,
    hour, quarterhour, minute, second,
    millisecond, microsecond, nanosecond,
    Centuries, Decades,
    Years, Quarters, Months, Weeks, Days,
    Hours, QuarterHours, Minutes, Seconds,
    Milliseconds, Microseconds, Nanoseconds,
    centuries, decades,
    years, quarters, months, weeks, days,
    hours, quarterhours, minutes, seconds,
    milliseconds, microseconds, nanoseconds,
    yr, qy, mo, dy, hr, qh, mi, sc, ms, us, ns,
    isostring,
    # pass through from Base.Dates
    Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday,
    Mon, Tue, Wed, Thu, Fri, Sat, Sun,
    January, February, March, April, May, June, July, August, September, October, November, December,
    Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec,
    # pass through from Base.Dates (essentially)
    totaldays, daysinmonth, daysinyear, isleapyear, yearmonth, yearmonthday,
    dayabbr, dayname, monthabbr, monthname,
    dayofweek, dayofmonth, dayofquarter, dayofyear,
    firstdayofweek, firstdayofmonth, firstdayofquarter, firstdayofyear,
    lastdayofweek, lastdayofmonth, lastdayofquarter, lastdayofyear,
    daysofweekinmonth,
    # pass through from TimeZones
    ZonedDateTime, TimeZone, astimezone, localzone, @tz_str


import Base.Dates:Date, DateTime, Time,
    datetime2rata, rata2datetime,
    datetime2unix, unix2datetime,
    date2epochdays, epochdays2date,
    Period, CompoundPeriod,
    Year, Month, Week, Day, Hour, Minute, Second,
    Millisecond, Microsecond, Nanosecond,
    year, month, week, day, hour, minute, second,
    millisecond, microsecond, nanosecond,
    value,
    # passthrough from Base.Dates
    Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday,
    Mon, Tue, Wed, Thu, Fri, Sat, Sun,
    January, February, March, April, May, June, July, August, September, October, November, December,
    Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec

const Int4Time = Int64
const Int4Span = Int64
const Time24 = Base.Dates.Time

include("types/Abstract.jl")
include("support/preference.jl")

include("support/string_support.jl")
include("support/chars.jl")
include("support/granular_consts.jl")
include("support/rata_conversion.jl")
include("support/passthrough.jl")
include("support/string_chars.jl")
include("support/string_to_smallint.jl")
include("support/nanosecs_to_string.jl")
include("support/parse_formatted.jl")

include("types/Grain/Granules.jl")
include("types/Grain/islte.jl")
include("types/Grain/units.jl")
include("types/Grain/intraconvert.jl")
include("types/Grain/interconvert.jl")
include("types/Grain/string.jl")
include("types/Grain/parse.jl")

include("types/Clock/Clock.jl")
include("types/Clock/UniversalTime.jl")
include("types/Clock/LocalTime.jl")
include("types/Clock/SimpleClock.jl")
include("types/Clock/whichframe.jl")

include("types/Duration/Duration.jl")
include("types/Duration/convert.jl")
include("types/Duration/parts.jl")
include("types/Duration/string.jl")
include("types/Duration/io.jl")
include("types/TimeSpan/TimeSpan.jl")
include("types/TimeSpan/arith.jl")
include("types/TimeSpan/string.jl")
include("types/TimeSpan/io.jl")

include("types/hash.jl")
include("types/type_utils.jl")

const Time24 = Base.Dates.Time
const NanoTime = Union{UniversalTime, LocalTime}

include("types/TimeSpan/periods.jl")
include("types/TimeSpan/parse.jl")

include("types/Clock/convert.jl")
include("types/Clock/string.jl")
include("types/Clock/io.jl")
include("types/Clock/arith.jl")
include("types/Clock/parse.jl")

include("types/ZonedDateTime.jl")

include("types/Duration/arith.jl")
include("types/Duration/parse.jl")

include("types/mixed/unions.jl")
include("types/mixed/arith.jl")
include("types/mixed/passthrough.jl")
include("types/mixed/Time24.jl")
include("types/mixed/parse.jl")

include("support/utm2local.jl")

end # module
